Repository navigation
export: erwin XML that opens in real erwin (numeric dialect + --template clone) - #65
Merged
Merged
Conversation
…-SA stubs)
The id-format fix (0.8.4) was necessary but not sufficient: a semantic diff against a real
erwin 10.10 export that erwin imports cleanly showed our exporter writes a DIFFERENT dialect,
and real erwin's import engine (EAT) still hung. Match the dialect erwin actually reads:
- Numeric enum codes instead of words (decoded from a real erwin 10.10 export; the published
XSD types these as free strings and does not carry the codes):
Relationship_Type 2 identifying / 7 non-identifying (was Identifying/Non_Identifying)
Cardinality -3 zero-one-or-more / -1 one (was Zero_One_or_More/One)
Null_Option_Type 0 null / 1 not null (was NULL/NOT_NULL)
Attribute Type 0 pk-member / 100 other (new)
Entity Type 1 (new)
Key_Group_Type PK / AKn / IFn (was Primary_Key/Alternate_Key/...)
- FileVersion 10.10.38485 (was 9.8.0000). Real erwin writes and imports the 10.10 form; the
published XSD pattern is stricter than erwin's own output and rejects it, so the XSD tests now
validate STRUCTURE against a schema-acceptable FileVersion. A real erwin import, not the XSD,
is the compatibility oracle.
- Scoped export: keep FKs WITHIN the subject area, DROP cross-area FKs instead of emitting a
thin stub entity (erwin chokes on stubs). Cross-area FKs are re-established in erwin after the
slice imports. Removes _emit_entity_stub.
The mdl_reverse importer now reads both the numeric codes and the old word forms, so round-trips
hold. Also hardens the word-form identifying read (the old 'identifying' in rtype matched
'non_identifying' too). Full suite: 1038 passed.
NOT YET VERIFIED against real erwin (no erwin in CI); built to the dialect observed in a real
10.10 export. The identifying-flag importer loss (erwin Type=2 dropped on import) is a separate
known bug, deferred.
… in real erwin
The self-built envelope (empty ModelProps, invented domains) opens in erwin DM
10.10 as an empty Model_1 and freezes the import engine at 100% CPU. The reliable
path, proven against real erwin, is to CLONE a native export of the target mart as
a template, strip its content, and inject Modelith's entities into that envelope.
emit_erwin(model, template=<path|bytes>) delegates to a new erwin_template module
that ports the erwin-verified reference tool (tools/ddl_to_erwin_xml.py), driven by
Modelith's IR instead of a parsed DDL script:
- clone the envelope (ModelProps, Domain_Groups, themes, images, page setup);
strip Entity/Relationship/Subject_Area/Diagram groups + Model_Proxy_Object;
remint the model id/name/Locator/Persistence_Unit; drop dangling *_Refs
- resolve domains BY NAME from the template (Number/String/d_date/d_bit), not
invented BOOLEAN/BIGINT
- entity Type 1/6 (dependent when it has an identifying parent)
- emit inferred PKs (role: business_key) as explicit XPK key groups
- full FK structure: parent Key_Group_Ref, child IFn key group with
Relationship_Ref + Parent_Key_Group_Member_Ref, FK attrs' Parent_Attribute_Ref
+ Parent_Relationship_Ref, Attributes_Order_Ref_Array
- relationship Null_Option_Type 101/100, Cardinality -1/-3, numeric Type 2/7
- a scoped export keeps within-area FKs and drops cross-area FKs (no stub)
- a preserved erwin_id is re-emitted verbatim so erwin UPDATES, not duplicates
Surfaces:
- CLI: mdl export erwin --template <mart.xml> [--name] (-t)
- API: POST /api/export/erwin multipart (the 7-10 MB template can't ride a query
param); the GET route still serves the self-built envelope
- canvas: Export menu "erwin XML (erwin-ready) - pick mart..." file picker that
POSTs the template and downloads the result, honouring the subject-area filter
Without --template the self-built envelope is unchanged (XSD-valid, round-trips via
mdl import erwin, not guaranteed to open in erwin). lxml added to emit-erd deps.
docs/modelith-erwin-xml-exporter.md captures the dialect spec; tools/ (the verbatim
reference script) is excluded from ruff. 807 tests pass; canvas tsc + 55 vitest pass.
# Conflicts: # packages/server/src/mdl_server/static/assets/ModelDiagram-B8BNKKus.js # packages/server/src/mdl_server/static/assets/ModelDiagram-B9WAgAKw.js # packages/server/src/mdl_server/static/assets/ModelDiagram-yDpS9fVd.js # packages/server/src/mdl_server/static/assets/main-CBJYBl0L.js # packages/server/src/mdl_server/static/assets/main-DzkzbaZK.js # packages/server/src/mdl_server/static/assets/main-W1aXYKPl.js # packages/server/src/mdl_server/static/assets/sme-C-aE5Tdu.js # packages/server/src/mdl_server/static/assets/sme-CoLqAg47.js # packages/server/src/mdl_server/static/assets/sme-N0VgjHK_.js # packages/server/src/mdl_server/static/assets/styles-Cw-0u507.js # packages/server/src/mdl_server/static/index.html # packages/server/src/mdl_server/static/sme.html
…plate
If you imported from an erwin export, re-exporting to erwin should reuse that
file as the template without re-picking it. `mdl import erwin` now records the
path it imported from in export.erwin.template_path (the PATH, not a committed
blob), and the erwin export resolves it automatically.
- ErwinExportConfig gains template_path; added to the writer's _USER_OWNED_CONFIG
so a re-import preserves it rather than wiping it
- CLI import stamps template_path (relative to the model root when the file lives
under it, else absolute)
- mdl export erwin resolves the template as: --template <file> > the remembered
path (unless --no-template) > none (self-built envelope). A remembered file that
has moved is reported and export falls back to the self-built envelope
- GET /api/export/erwin auto-clones the remembered template; /api/export reports
erwinTemplateRemembered so the canvas Export menu shows the plain "erwin XML"
item as "erwin-ready" and relabels the picker to "clone a different mart..."
End to end: import sample.erwin.xml -> export erwin re-clones it (output carries the
template's envelope), verified. 814 tests pass (8 new), ruff clean; canvas tsc + 55
vitest pass, bundle rebuilt.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two commits on the XML-export path to erwin Data Modeler 10.10. The first fixes the per-object dialect; the second is the one that actually gets a file to open in real erwin without freezing — clone a native export as a template and inject the model into it.
1.
e693e0d— numeric enum dialecterwin 10.10 writes enums as NUMERIC codes, not words. Emitting the word forms (
Non_Identifying,Zero_One_or_More) hung erwin's import engine (EAT). Now emits the codes; the importer reads both, so round-trips hold.Type1, AttributeType0/100,Null_Option_Type0/1, RelationshipType2/7,Cardinality-3/-1,Key_Group_TypePK/AK1/IF1,FileVersion10.10.38485.2.
516381f—--template: clone a native export so the file opens in erwinThe self-built envelope (empty
ModelProps, invented domains) opens as an emptyModel_1and freezes erwin at 100% CPU. The reliable path, proven against real erwin, is to clone a native export of the target mart as a template, strip its content, and inject Modelith's entities into that envelope.emit_erwin(model, template=<path|bytes>)delegates to a newerwin_templatemodule that ports the erwin-verified reference tool (tools/ddl_to_erwin_xml.py), driven by Modelith's IR instead of a parsed DDL script:Model_Proxy_Object; remint model id/name/Locator/Persistence_Unit; drop dangling*_Refs.Number/String/d_date/d_bit), not inventedBOOLEAN/BIGINT.Type6 when it has an identifying parent.role: business_key) emitted as explicitXPKkey groups.Key_Group_Ref, childIFnkey group withRelationship_Ref+Parent_Key_Group_Member_Ref, FK attrs'Parent_Attribute_Ref+Parent_Relationship_Ref,Attributes_Order_Ref_Array.Null_Option_Type101/100.erwin_idre-emitted verbatim (erwin updates, not duplicates).Surfaces
mdl export erwin --template <mart.xml> [--name](-t).POST /api/export/erwinmultipart — the 7–10 MB template can't ride a query param; the GET route still serves the self-built envelope.Without
--template, the self-built envelope is unchanged (XSD-valid, round-trips viamdl import erwin, not guaranteed to open in erwin).lxmladded toemit-erddeps.docs/modelith-erwin-xml-exporter.mdcaptures the dialect spec;tools/ddl_to_erwin_xml.pyis the verbatim erwin-verified reference (excluded from ruff).Verified
807 tests pass (10 new template + 2 API); ruff clean on packages; canvas tsc clean + 55 vitest; canvas bundle rebuilt. Not verified against real erwin in CI (no erwin on the runner) — built to the reference tool's erwin-verified output. The real test is
mdl export erwin --template <your mart.xml>→ File > Open > XML in erwin 10.10.🤖 Generated with Claude Code
3.
494e656— remember the imported erwin file, auto-clone on exportIf the model was imported from an erwin export, re-exporting reuses that file as the template with no flag and no re-picking:
mdl import erwinrecords the path it imported from inexport.erwin.template_path(the path, not a committed blob; preserved across re-imports).mdl export erwinresolves the template as--template <file>> remembered path (unless--no-template) > none (self-built envelope). A remembered file that has moved is reported and export falls back to self-built./api/exportreportserwinTemplateRemembered, so the plain erwin XML item shows · erwin-ready and the picker relabels to clone a different mart….Verified end to end: import
sample.erwin.xml→mdl export erwinlogs cloning remembered erwin template and the output carries the template envelope.